package org.sy.lab.多线程基础._1_管理._6_线程组;

import java.util.concurrent.TimeUnit;

public class Main {

	public static void main(String[] args) {
		
		MyThread myThread = new MyThread();
		ThreadGroup group = new ThreadGroup("xs");
		for(int i=0; i<5; i++) {
			Thread thread = new Thread(group, myThread);
			thread.start();
		}
		
		try {
			TimeUnit.SECONDS.sleep(1);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		
		System.out.println("线程数量：" + group.activeCount());
		
		group.list();
		
		Thread[] threads = new Thread[group.activeCount()];
		group.enumerate(threads);
		for (int i = 0; i < threads.length; i++) {
			System.out.println("线程" + threads[i].getName() + "状态：" + threads[i].getState() + " id：" + threads[i].getId());
		}
	}
}
